package com.fei.yygh.excption;

import com.fei.yygh.result.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExcptionHandler {
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result error(Exception e) {

        e.printStackTrace();
        return Result.fail();
    }

    //自定义的错误异常
    @ExceptionHandler(value = YyghException.class)
    @ResponseBody
    public Result yygh(YyghException e) {
        e.printStackTrace();
        return Result.fail();
    }
}
